//
//  SubmitModel.swift
//  ShopIOS
//
//  Created by Apple on 2019/7/30.
//  Copyright © 2019 Apple. All rights reserved.
//

import Foundation
import SwiftyJSON

struct SubmitModel {
    var InvoiceContext = [SubmitModelInvoiceContext]()
    var IsOpenStore: Bool = false
    var Freight: Int = 0
    var Success: String?
    var userIntegrals: Int = 0
    var orderAmount: Int = 0
    var Address: SubmitModelAddress?
    var TotalAmount: Int = 0
    var IsCashOnDelivery: Bool = false
    var products = [SubmitModelProducts]()
    var integralPerMoney: Int = 0
    
    init(json: JSON) {
        InvoiceContext = json["InvoiceContext"].arrayValue.compactMap({ SubmitModelInvoiceContext(json: $0)})
        IsOpenStore = json["IsOpenStore"].boolValue
        Freight = json["Freight"].intValue
        Success = json["Success"].stringValue
        userIntegrals = json["userIntegrals"].intValue
        orderAmount = json["orderAmount"].intValue
        Address = SubmitModelAddress(json: json["Address"])
        TotalAmount = json["TotalAmount"].intValue
        IsCashOnDelivery = json["IsCashOnDelivery"].boolValue
        products = json["products"].arrayValue.compactMap({ SubmitModelProducts(json: $0)})
        integralPerMoney = json["integralPerMoney"].intValue
    }
}

struct SubmitModelAddress {
    var Address: String?
    var RegionId: Int = 0
    var Id: Int = 0
    var Phone: String?
    var ShipTo: String?
    
    init(json: JSON) {
        Address = json["Address"].stringValue
        RegionId = json["RegionId"].intValue
        Id = json["Id"].intValue
        Phone = json["Phone"].stringValue
        ShipTo = json["ShipTo"].stringValue
    }
}

struct SubmitModelInvoiceContext {
    var Id: Int = 0
    var Name: String?
    
    init(json: JSON) {
        Id = json["Id"].intValue
        Name = json["Name"].stringValue
    }
}

struct SubmitModelCartItemModels {
    var ColorAlias: String?
    var color: String?
    var id: Int = 0
    var minPrice: Int = 0
    var size: String?
    var shopName: String?
    var price: Int = 0
    var IsSelf: Bool = false
    var productCode: String?
    var name: String?
    var skuId: String?
    var UserCoupons: String?
    var imgUrl: String?
    var isDis: Bool = false
    var ShopBranchName: String?
    var version: String?
    var vshopId: Int = 0
    var count: Int = 0
    var SizeAlias: String?
    var ShopBranchId: String?
    var shopId: Int = 0
    var unit: String?
    var VersionAlias: String?
    var IsLimit: Bool = false
    var collpid: Int = 0
    
    init(json: JSON) {
        ColorAlias = json["ColorAlias"].stringValue
        color = json["color"].stringValue
        id = json["id"].intValue
        minPrice = json["minPrice"].intValue
        size = json["size"].stringValue
        shopName = json["shopName"].stringValue
        price = json["price"].intValue
        IsSelf = json["IsSelf"].boolValue
        productCode = json["productCode"].stringValue
        name = json["name"].stringValue
        skuId = json["skuId"].stringValue
        UserCoupons = json["UserCoupons"].stringValue
        imgUrl = json["imgUrl"].stringValue
        isDis = json["isDis"].boolValue
        ShopBranchName = json["ShopBranchName"].stringValue
        version = json["version"].stringValue
        vshopId = json["vshopId"].intValue
        count = json["count"].intValue
        SizeAlias = json["SizeAlias"].stringValue
        ShopBranchId = json["ShopBranchId"].stringValue
        shopId = json["shopId"].intValue
        unit = json["unit"].stringValue
        VersionAlias = json["VersionAlias"].stringValue
        IsLimit = json["IsLimit"].boolValue
        collpid = json["collpid"].intValue
    }
}

struct SubmitModelProducts {
    var ShopTotalWithoutFreight: Int = 0
    var IsSelf: Bool = false
    var ShopName: String?
    var OneCoupons: String?
    var BaseCoupons: String?
    var ProvideInvoice: Bool = false
    var ShopTotal: Int = 0
    var freightProductGroup: String?
    var UserBonus: String?
    var Freight: Int = 0
    var ShopBranchId: String?
    var FullDiscount: Int = 0
    var VshopId: Int = 0
    var ExistShopBranch: Bool = false
    var FreeFreight: Int = 0
    var shopId: Int = 0
    var ShopBranchName: String?
    var CartItemModels = [SubmitModelCartItemModels]()
    var IsFreeFreight: Bool = false
    
    init(json: JSON) {
        ShopTotalWithoutFreight = json["ShopTotalWithoutFreight"].intValue
        IsSelf = json["IsSelf"].boolValue
        ShopName = json["ShopName"].stringValue
        OneCoupons = json["OneCoupons"].stringValue
        BaseCoupons = json["BaseCoupons"].stringValue
        ProvideInvoice = json["ProvideInvoice"].boolValue
        ShopTotal = json["ShopTotal"].intValue
        freightProductGroup = json["freightProductGroup"].stringValue
        UserBonus = json["UserBonus"].stringValue
        Freight = json["Freight"].intValue
        ShopBranchId = json["ShopBranchId"].stringValue
        FullDiscount = json["FullDiscount"].intValue
        VshopId = json["VshopId"].intValue
        ExistShopBranch = json["ExistShopBranch"].boolValue
        FreeFreight = json["FreeFreight"].intValue
        shopId = json["shopId"].intValue
        ShopBranchName = json["ShopBranchName"].stringValue
        CartItemModels = json["CartItemModels"].arrayValue.compactMap({ SubmitModelCartItemModels(json: $0)})
        IsFreeFreight = json["IsFreeFreight"].boolValue
    }
}

